package com.tac.controller;

import com.tac.common.result.Result;
import com.tac.pojo.Footprint;
import com.tac.pojo.Product;
import com.tac.service.FootprintService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/footprint")
@RestController
@CrossOrigin
@Api(value = "足迹",tags ="足迹" )
public class FootprintController {
    @Autowired
    private FootprintService footprintService;
    /**
     * 删除足迹
     * @param
     * @return
     */
    @ApiOperation("删除足迹")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    @DeleteMapping("/{pid}")
    public Result remove(@PathVariable Integer pid){
        return footprintService.remove(pid);
    }


    /**
     * 查看收藏所有商品 按时间倒序排列
     * @param
     * @return
     */
    @ApiOperation("查看收藏所有商品")
    @GetMapping
    public Result<List<Product>> selectByUid(){
        return footprintService.selectByUid();
    }
    /**
     * 管理员查看足迹所有商品 按时间倒序排列
     * @param
     * @return
     */
    @ApiOperation("管理员查看足迹所有商品")
    @GetMapping("/selectAll")
    public Result<List<Footprint>> selectAll(){
        return footprintService.selectAll();
    }
    /**
     * 管理员删除足迹
     * @param pid
     * @param uid
     * @return
     */
    @DeleteMapping("/{pid}/{uid}")
    @ApiOperation("管理员删除足迹")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public Result delete(@PathVariable Integer pid,@PathVariable Integer uid){
        return footprintService.delete(pid,uid);
    }
}
